package me.liquidifica.persistence.entities;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Persistence;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * Entidade respons�vel por representar os usu�rios do sistema
 * @author dfrodriguesbh
 */
@Data
@Entity
@AllArgsConstructor
@NoArgsConstructor
@NamedQueries(value={
	@NamedQuery(name="Usuario.obterUsuario", query="SELECT usr FROM Usuario usr WHERE usr.usuario = :usuario AND usr.senha = :senha"),
	@NamedQuery(name="Usuario.obterTodosUsuario", query="SELECT usr FROM Usuario usr")
})
public class Usuario implements Serializable {

	private static final long serialVersionUID = 1L;

	@Id
	@Column(name="id")
	private long cpf;

	private String nome;

	private String usuario;
	
	private String senha;
	
	private String email;
	
	@OneToOne(fetch=FetchType.EAGER)
	@JoinColumn(name="idEndereco")
	private Endereco endereco;
	
	@OneToMany(mappedBy="id", fetch=FetchType.EAGER)
	private List<Atividade> atividades;
	
}
